<a href="http://github.com/angular/angular.js/tree/v1.2.9/src/ng/directive/input.js#L1125" class="view-source btn btn-action"><i class="icon-zoom-in"> </i> View source</a><a href="http://github.com/angular/angular.js/edit/master/src/ng/directive/input.js" class="improve-docs btn btn-primary"><i class="icon-edit"> </i> Improve this doc</a><h1><code ng:non-bindable="">ngModel</code>
<div><span class="hint">directive in module <code ng:non-bindable="">ng</code>
</span>
</div>
</h1>
<div><h2 id="description">Description</h2>
<div class="description"><div class="ng-directive-page ng-directive-ngmodel-page"><p>The <code>ngModel</code> directive binds an <code>input</code>,<code>select</code>, <code>textarea</code> (or custom form control) to a
property on the scope using <a href="api/ng.directive:ngModel.NgModelController"><code>NgModelController</code></a>,
which is created and exposed by this directive.</p>
<p><code>ngModel</code> is responsible for:</p>
<ul>
<li>Binding the view into the model, which other directives such as <code>input</code>, <code>textarea</code> or <code>select</code>
require.</li>
<li>Providing validation behavior (i.e. required, number, email, url).</li>
<li>Keeping the state of the control (valid/invalid, dirty/pristine, validation errors).</li>
<li>Setting related css classes on the element (<code>ng-valid</code>, <code>ng-invalid</code>, <code>ng-dirty</code>, <code>ng-pristine</code>).</li>
<li>Registering the control with its parent <a href="api/ng.directive:form"><code>form</code></a>.</li>
</ul>
<p>Note: <code>ngModel</code> will try to bind to the property given by evaluating the expression on the
current scope. If the property doesn&#39;t already exist on this scope, it will be created
implicitly and added to the scope.</p>
<p>For best practices on using <code>ngModel</code>, see:</p>
<ul>
<li><a href="https://github.com/angular/angular.js/wiki/Understanding-Scopes"><a href="https://github.com/angular/angular.js/wiki/Understanding-Scopes">https://github.com/angular/angular.js/wiki/Understanding-Scopes</a></a></li>
</ul>
<p>For basic examples, how to use <code>ngModel</code>, see:</p>
<ul>
<li><a href="api/ng.directive:input"><code>input</code></a><ul>
<li><a href="api/ng.directive:input.text"><code>text</code></a></li>
<li><a href="api/ng.directive:input.checkbox"><code>checkbox</code></a></li>
<li><a href="api/ng.directive:input.radio"><code>radio</code></a></li>
<li><a href="api/ng.directive:input.number"><code>number</code></a></li>
<li><a href="api/ng.directive:input.email"><code>email</code></a></li>
<li><a href="api/ng.directive:input.url"><code>url</code></a></li>
</ul>
</li>
<li><a href="api/ng.directive:select"><code>select</code></a></li>
<li><a href="api/ng.directive:textarea"><code>textarea</code></a></li>
</ul>
</div></div>
<h2 id="usage">Usage</h2>
<div class="usage">as attribute<pre class="prettyprint linenums">&lt;input ng-model&gt;
   ...
&lt;/input&gt;</pre>
</div>
</div>
